/*
 * MockFileHandler.h
 *
 *  Created on: Nov 23, 2012
 *      Author: Federico Orquera
 */

#ifndef MOCKFILEHANDLER_H_
#define MOCKFILEHANDLER_H_

#include <vector>
#include <iostream>
#include <string>
#include "../fileHandler/FileHandlerInterface.h"

class MockFileHandler: public virtual SignatureSlicingIndex::FileHandlerInterface<32> {

public:
	typedef SignatureSlicingIndex::FileHandlerInterface<32>::Slice	Slice;
	typedef std::shared_ptr		< Slice >							Slice_ptr;
	typedef SignatureSlicingIndex::KeyWordID						KeyWordID;

	MockFileHandler(const std::string& fileName):FileHandlerInterface(fileName){
		(this->Slices).resize(200);
	}

	virtual ~MockFileHandler(){}

	virtual Slice_ptr getSlice( const KeyWordID& keyWord ){
		if( Slices[ keyWord ].get() != NULL ) return Slices[ keyWord ];
		return this->getNewSlice(keyWord);
	}

	virtual void saveSlice( const Slice_ptr& slice ){}

	void updateSliceBit( const size_t sliceNumber, size_t bitNumber, bool value ){}

private:

	std::vector< Slice_ptr > Slices;

	KeyWordID GenerateID(){
		static KeyWordID c_ID = 0;
		return c_ID++;
	}

	virtual Slice_ptr getNewSlice(const KeyWordID& ID ){
		Slice_ptr newSlice( new Slice(ID) );
		Slices[newSlice->getID()] = newSlice;
		return newSlice;
	}
};

#endif /* MOCKFILEHANDLER_H_ */
